package xyz.xtt.equity.client;

import java.util.List;
import java.util.Map;

import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import cn.hutool.json.JSONUtil;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import xyz.xtt.asset.client.response.AssetAllInfoResponse;
import xyz.xtt.common.response.ApiResult;
import xyz.xtt.equity.api.dto.GetBenefitPurchaseRecordRequest;
import xyz.xtt.equity.api.dto.GetOnSaleBenefitPackageRequest;
import xyz.xtt.equity.api.dto.SaveBenefitPurchaseUnPayDto;
import xyz.xtt.equity.api.dto.TblBenefitPackageDto;
import xyz.xtt.equity.api.dto.TblBenefitPurchaseRecordDto;
import xyz.xtt.equity.api.dto.TblUserBenefitByAssetIdDto;
import xyz.xtt.equity.client.request.BlockAssetNoBenefitRequest;
import xyz.xtt.equity.client.request.GetUnPayBenefitPurchaseRecordRequest;
import xyz.xtt.equity.client.request.HandlePayCancelRequest;
import xyz.xtt.equity.client.request.HandlePaySuccessRequest;
import xyz.xtt.equity.client.request.SendAssetNoBenefitRequest;
import xyz.xtt.equity.client.request.SendDeliverResultRequest;
import xyz.xtt.equity.client.request.SendFreeBenefitPackageRequest;
import xyz.xtt.equity.client.request.TblUserBenefitDto;
import xyz.xtt.equity.client.request.UnBlockAssetNoBenefitRequest;
import xyz.xtt.equity.client.response.AssetEntitlementResponse;

@Slf4j
@Component
public class EquityClientFallbackFactory implements FallbackFactory<EquityClient> {
	@Override
	public EquityClient create(Throwable throwable) {
		return new EquityClient() {

//			@Override
//			public ApiResult<Boolean> deliver(DeliverRequest deliverRequest) {
//				log.info("deliver FallbackFactory param: {}", JSONUtil.toJsonStr(deliverRequest));
//				return ApiResult.failure();
//			}

//			@Override
//			public ApiResult<MintResponse> create(String uid,  MintRequest mintRequest) {
//				log.info("create FallbackFactory param: {}", JSONUtil.toJsonStr(mintRequest));
//				return ApiResult.failure();
//			}
//
//			@Override
//			public ApiResult<MintResponse> mint(String uid, MintRequest mintRequest) {
//				log.info("mint FallbackFactory param: {}", JSONUtil.toJsonStr(mintRequest));
//				return ApiResult.failure();
//			}
//
//			@Override
//			public ApiResult<TransferFromResponse> transferFrom(String uid, TransferFromRequest transferFromRequest) {
//				log.info("mint FallbackFactory param: {}", JSONUtil.toJsonStr(transferFromRequest));
//				return ApiResult.failure();
//			}

//			@Override
//			public ApiResult<List<TblPayOrderDto>> fetchUnPaidOrders(FetchUnPaidOrdersRequest fetchRequest) {
//				log.info("fetchUnPaidOrders FallbackFactory param: {}", JSONUtil.toJsonStr(fetchRequest));
//				return ApiResult.failure();
//			}

//			@Override
//			public ApiResult<Boolean> confirmPayStatus(ConfirmPayOrderRequest confirmRequest) {
//				log.info("confirmPayStatus FallbackFactory param: {}", JSONUtil.toJsonStr(confirmRequest));
//				return ApiResult.failure();
//			}
//
//			@Override
//			public ApiResult<Integer> getPayStatus(GetPayStatusRequest request) {
//				log.info("getPayStatus FallbackFactory param: {}", JSONUtil.toJsonStr(request));
//				return ApiResult.failure();
//			}
//
//			@Override
//			public ApiResult<Map<Long, Integer>> getPayStatusMap(GetPayStatusMapRequest request) {
//				log.info("getPayStatusMap FallbackFactory param: {}", JSONUtil.toJsonStr(request));
//				return ApiResult.failure();
//			}
//
//			@Override
//			public ApiResult<Map<Long, Long>> collectionStatis() {
//				log.info("collectionStatis FallbackFactory ");
//				return ApiResult.failure();
//			}
//
//			@Override
//			public ApiResult<Map<Long, Long>> roseStatis() {
//				log.info("roseStatis FallbackFactory ");
//				return ApiResult.failure();
//			}

//			@Override
//			public ApiResult<Boolean> assistantMessage(AssistantMessageRequest request) {
//				log.info("assistantMessage FallbackFactory");
//				return ApiResult.failure();
//			}

//			@Override
//			public ApiResult<TblPayOrderDto> fetchPayOrder(Long payOrderId) {
//				log.info("fetchPayOrder FallbackFactory param: {}", payOrderId);
//				return ApiResult.failure();
//			}

//			@Override
//			public ApiResult<List<TblAssetCardDto>> getUserCardInfo(CardInfoRequest cardInfoRequest) {
//				log.info("fetchPayOrder getUserCardInfo param: {}", cardInfoRequest);
//				return ApiResult.failure();
//			}

//			@Override
//			public ApiResult<List<BusinessOrderDto>> selectListByGoodsIds(BusinessOrderRequest businessOrderRequest) {
//				log.info("fetchPayOrder selectListByGoodsIds param: {}", businessOrderRequest);
//				return ApiResult.failure();
//			}
//
//			@Override
//			public ApiResult<Map<Long, BusinessOrderDto>> getBusinessListByIds(Set<Long> ids) {
//				log.info("fetchPayOrder getBusinessListByIds param: {}", ids);
//				return ApiResult.failure();
//			}

//			@Override
//			public ApiResult<List<TblUserFundRecordDto>> getNeedSettleRecords(Integer maxCount, Long lastId) {
//				log.info("getNeedSettleRecords FallbackFactory param: {},{}", maxCount, lastId);
//				return ApiResult.failure();
//			}
//
//			@Override
//			public ApiResult<Boolean> updateFundSettled(UpdateFundSettledRequest request) {
//				log.info("updateFundSettled FallbackFactory param: {}", JSONUtil.toJsonStr(request));
//				return ApiResult.failure();
//			}

			@Override
			public ApiResult<List<AssetEntitlementResponse>> assetEntitlementWithAssetId(Long assetId) {
				log.info("assetEntitlementWithAssetId FallbackFactory assetId: {}", assetId);
				return ApiResult.failure();
			}

//			@Override
//			public ApiResult<List<Long>> entitlementDeliver(Long assetId, Long appUid) {
//				log.info("assetEntitlementWithAssetId FallbackFactory assetId:{},appUid:{}", assetId, appUid);
//				return ApiResult.failure();
//			}

			@Override
			public ApiResult<Boolean> isVip(Long appUid) {
				log.info("assetEntitlementWithAssetId FallbackFactory appUid:{}", appUid);
				return ApiResult.failure();
			}

			@Override
			public ApiResult<Boolean> deliverCheck(Long entitlementId, Long uid) {
				log.info("assetEntitlementWithAssetId FallbackFactory entitlementId:{},appUid:{}", entitlementId, uid);
				return ApiResult.failure();
			}

//			@Override
//			public ApiResult<xyz.xtt.asset.client.response.TransferFromResponse> transferFrom(String platform,
//					xyz.xtt.asset.client.request. TransferFromRequest transferFromRequest) {
//				// TODO Auto-generated method stub
//				return null;
//			}

			@Override
			public ApiResult<TblUserBenefitDto> getLatestUserBenefit(String uid, String benefitCode) {
				log.info("getLatestUserBenefit FallbackFactory uid:{},benefitCode:{}", uid, benefitCode);
				return ApiResult.failure();
			}

			@Override
			public ApiResult<TblBenefitPackageDto> getOnSaleBenefitPackage(GetOnSaleBenefitPackageRequest request) {
				log.info("getOnSaleBenefitPackage FallbackFactory body:{}", JSONUtil.toJsonStr(request));
				return ApiResult.failure();
			}

			@Override
			public ApiResult<TblBenefitPurchaseRecordDto> getBenefitPurchaseRecord(Long uid, GetBenefitPurchaseRecordRequest request) {
				log.info("getBenefitPurchaseRecord FallbackFactory body:{}", JSONUtil.toJsonStr(request));
				return ApiResult.failure();
			}

			@Override
			public ApiResult<Boolean> handlePaySuccess(Long uid, HandlePaySuccessRequest request) {
				log.info("handlePaySuccess FallbackFactory body:{}", JSONUtil.toJsonStr(request));
				return ApiResult.failure();
			}

			@Override
			public ApiResult<Boolean> handlePayCancel(Long uid, HandlePayCancelRequest request) {
				log.info("handlePayCancel FallbackFactory uid:{},body:{}", uid, JSONUtil.toJsonStr(request));
				return ApiResult.failure();
			}

			@Override
			public ApiResult<TblBenefitPurchaseRecordDto> getUnPayBenefitPurchaseRecord(Long uid, GetUnPayBenefitPurchaseRecordRequest request) {
				log.info("getUnPayBenefitPurchaseRecord FallbackFactory uid:{},body:{}", uid, JSONUtil.toJsonStr(request));
				return ApiResult.failure();
			}

			@Override
			public ApiResult<Long> saveUnPayBenefitPurchase(Long uid, SaveBenefitPurchaseUnPayDto saveDto) {
				log.info("saveUnPayBenefitPurchase FallbackFactory uid:{},body:{}", uid, JSONUtil.toJsonStr(saveDto));
				return ApiResult.failure();
			}

			@Override
			public ApiResult<AssetAllInfoResponse> benefitPackageBaseInfo(Long benefitPackageId) {
				log.info("saveUnPayBenefitPurchase FallbackFactory benefitPackageId:{}", benefitPackageId);
				return ApiResult.failure();
			}

			@Override
			public ApiResult<Map<String, Integer>> getUserBenefits(long appUserId, String benefitCodes) {
				log.info("getUserBenefits FallbackFactory appUserId:{},benefitCodes:{}", appUserId, benefitCodes);
				return ApiResult.failure();
			}

			@Override
			public ApiResult<Boolean> userBenefitConsumed(long appUserId, String benefitCode, int consumeNum, Long operateBusinessId, String operateDesc) {
				log
						.info("userBenefitConsumed FallbackFactory appUserId:{},benefitCode:{},consumeNum:{},operateBusinessId:{},operateDesc:{}", appUserId, benefitCode, consumeNum, operateBusinessId, operateDesc);
				return ApiResult.failure();
			}

			@Override
			public ApiResult<Integer> userBenefitConsumeAsMuchAsPossible(long appUserId, String benefitCode, int consumeNum, Long operateBusinessId,
					String operateDesc) {
				log
						.info("userBenefitConsumeAsMuchAsPossible FallbackFactory appUserId:{},benefitCode:{},consumeNum:{},operateBusinessId:{},operateDesc:{}", appUserId, benefitCode, consumeNum, operateBusinessId, operateDesc);
				return ApiResult.failure();
			}

			@Override
			public ApiResult<Boolean> userBenefitRecover(long appUserId, Long operateBusinessId, String operateDesc) {
				log.info("getUserBenefits FallbackFactory appUserId:{},operateBusinessId:{},operateDesc:{}", appUserId, operateBusinessId, operateDesc);
				return ApiResult.failure();
			}

			@Override
			public ApiResult<List<Long>> entitlementDeliver(Long assetId, Long appUid) {
				log.info("entitlementDeliver FallbackFactory assetId:{},appUid:{}", assetId, appUid);
				return ApiResult.failure();
			}

			@Override
			public ApiResult<Boolean> installByPackageIds(String packageIds, Long assetId) {
				log.info("installByPackageIds FallbackFactory packageIds:{},assetId:{}", packageIds, assetId);
				return ApiResult.failure();
			}

			@Override
			public ApiResult<Boolean> sendFreeBenefitPackage(@Valid SendFreeBenefitPackageRequest request) {
				log.info("sendFreeBenefitPackage FallbackFactory request:{}", JSONUtil.toJsonStr(request));
				return ApiResult.failure();
			}

			@Override
			public ApiResult<Boolean> sendAssetNoBenefit(@Valid SendAssetNoBenefitRequest request) {
				log.info("sendAssetNoBenefit FallbackFactory request:{}", JSONUtil.toJsonStr(request));
				return ApiResult.failure();
			}

			@Override
			public ApiResult<List<TblBenefitPackageDto>> getPackageByIds(List<Long> packageIds) {
				log.info("getPackageByIds FallbackFactory request:{}", JSONUtil.toJsonStr(packageIds));
				return ApiResult.failure();
			}

			@Override
			public ApiResult<Boolean> unBlockAssetNoBenefit(UnBlockAssetNoBenefitRequest unBlockAssetNoBenefitRequest) {
				log.info("unBlockAssetNoBenefit FallbackFactory request:{}", JSONUtil.toJsonStr(unBlockAssetNoBenefitRequest));
				return ApiResult.failure();
			}

			@Override
			public ApiResult<Boolean> blockAssetNoBenefit(BlockAssetNoBenefitRequest blockAssetNoBenefitRequest) {
				log.info("blockAssetNoBenefit FallbackFactory request:{}", JSONUtil.toJsonStr(blockAssetNoBenefitRequest));
				return ApiResult.failure();
			}

			@Override
			public ApiResult<Boolean> saveDeliverResult(SendDeliverResultRequest request) {
				log.info("saveDeliverResult FallbackFactory request:{}", JSONUtil.toJsonStr(request));
				return ApiResult.failure();
			}

			@Override
			public ApiResult<TblUserBenefitByAssetIdDto> getBenefitDetailInfo(String uid, String assetId) {
				log.info("getBenefitDetailInfo FallbackFactory uid:{},assetId:{}", uid, assetId);
				return ApiResult.failure();
			}

//			@Override
//			public ApiResult<AssetEntitlementResponse> assetEntitlementWithAssetId(Long assetId) {
//				log.info("assetEntitlementWithAssetId FallbackFactory param: {}", assetId);
//				return ApiResult.failure();
//			}

		};
	}
}
